import {
  Column,
  Entity,
  PrimaryGeneratedColumn,
  OneToOne,
  JoinColumn,
} from 'typeorm';
import { Doctor } from '../../doctor/entities/doctor.entity';

import { BaseEntity } from '../../../infra/entity/base';

@Entity()
export class WxUser extends BaseEntity {
  @PrimaryGeneratedColumn()
  id: number;

  @Column('varchar', { length: 40 })
  username: string;

  @Column('varchar', { length: 255 })
  avatar: string;

  @Column('smallint', { default: 0, nullable: true, comment: '0: 女 1: 男' })
  gender: number;

  @Column('varchar', { length: 11, unique: true })
  phone: string;

  // 新增用户角色字段，默认值为 0（普通用户）
  @Column({ type: 'tinyint', default: 0 })
  role: number;

  // 关联医生信息，可为空
  @OneToOne(() => Doctor, { nullable: true })
  @JoinColumn()
  doctor: Doctor;
}
